list-[id].vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div id="newsList">
  3. <!-- 页面头部 -->
  4. <HomePageHead></HomePageHead>
  5. <!-- 导航栏 -->
  6. <HomePageNavigation></HomePageNavigation>
  7. <!-- 列表页广告一 -->
  8. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  9. <!-- 二级标题-->
  10. <HomeListSecondaryHeading v-if="parent_name != ''" :name="parent_name" :nav="secondNav" :pinyin="parent_pinyin">
  11. </HomeListSecondaryHeading>
  12. <!-- 资讯列表 -->
  13. <main class="index_main">
  14. <!-- 面包屑导航 -->
  15. <div class="breadcrumb phone_none">
  16. <div class="inner">
  17. <span class="location">当前位置:</span>
  18. <el-breadcrumb :separator-icon="ArrowRight">
  19. <el-breadcrumb-item>
  20. <NuxtLink to="/">首页</NuxtLink>
  21. </el-breadcrumb-item>
  22. <el-breadcrumb-item v-if="parent_name != ''">
  23. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  24. </el-breadcrumb-item>
  25. <el-breadcrumb-item>{{ name }}</el-breadcrumb-item>
  26. </el-breadcrumb>
  27. </div>
  28. </div>
  29. <div class="breadcrumb_box pc_none">
  30. <span class=" ">当前位置:</span>
  31. <NuxtLink to="/">首页</NuxtLink>
  32. <span class=" " v-if="parent_name !=''">&gt;</span>
  33. <NuxtLink v-if="parent_name !=''" :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  34. <span class="" >&gt;</span>
  35. <span class="" >{{ name }}</span>
  36. </div>
  37. <section class="img_ul_box clearfix">
  38. <div class="img_li slow_6 phone_none" v-for="(item, index) in newsList" :key="index">
  39. <NuxtLink class="img_li_a clearfix" :href="getLinkPathDetail(item)" :title="item.title">
  40. <h4 class="img_li_h4 dot1">{{ item.title }}</h4>
  41. <div class="img_li_in clearfix">
  42. <div class="img_li_left">
  43. <div class="img_li_left_foto_box">
  44. <img class="img_li_left_foto" :src="item.imgurl" :title="item.title"
  45. :alt="item.title">
  46. </div>
  47. <div class="img_li_left_dot1 dot1">{{ item.title }}</div>
  48. </div>
  49. <div class="img_li_right">
  50. <div class="img_li_right_dot5 dot5">
  51. {{ item.description }}
  52. </div>
  53. <div class="img_li_right_detail">【查看详情】</div>
  54. </div>
  55. </div>
  56. </NuxtLink>
  57. </div>
  58. <div class="phone_li pc_none" v-for="(item, index) in newsList" :key="index">
  59. <NuxtLink class="phone_li_a clearfix" :href="getLinkPathDetail(item)" >
  60. <h4 class="phone_li_h4 dot1">{{ item.title }}</h4>
  61. <div class="phone_li_in clearfix">
  62. <div class="phone_li_img_box">
  63. <img class="" :src="item.imgurl" :alt="item.title">
  64. </div>
  65. <div class="phone_li_right">
  66. <div class="phone_li_dot4">
  67. {{ item.description }}
  68. </div>
  69. <div class="phone_li_btn">【查看详情】</div>
  70. </div>
  71. </div>
  72. </NuxtLink>
  73. </div>
  74. <div class="empty" v-if="newsList == false">
  75. <img src="@/public/topic/empty.png" alt="" class="empty_img">
  76. <span class="empty_text">当前暂无数据</span>
  77. </div>
  78. </section>
  79. <!-- 分页器 -->
  80. <div class="pagination page_phone_none" v-if="total > 0">
  81. <el-pagination size="small" background layout="prev, pager, next" :total="total" class="mt-4"
  82. :page-size="pageSize" :current-page="pageNum" prev-text="上一页" next-text="下一页"
  83. @current-change="changePage" />
  84. </div>
  85. <div class="pagination page_pc_none" v-if="total > 0">
  86. <el-pagination pager-count="5" size="small" background layout=" pager " :total="total"
  87. class="mt-4" :page-size="pageSize" :current-page="pageNum"
  88. @current-change="changePage" />
  89. </div>
  90. </main>
  91. <!-- 列表页广告二 -->
  92. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  93. <!-- 页面底部 -->
  94. <HomeFoot1></HomeFoot1>
  95. </div>
  96. </template>
  97. <script setup>
  98. //1.页面必备依赖 start ---------------------------------------->
  99. import { ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus'
  100. import { ArrowRight } from '@element-plus/icons-vue'
  101. import { ref, onMounted } from 'vue';
  102. //1.页面必备依赖 end ---------------------------------------->
  103. //2.路径 start---------------------------------------->
  104. //当前列表名称
  105. const route = useRoute();
  106. let articleId = 0;//列表需要使用的导航id
  107. let routeName;
  108. const targetSegment1 = getRoutePath(1);//根据路由反向查询导航id
  109. const targetSegment2 = getRoutePath(2);//根据路由反向查询导航id
  110. let pageNum = ref(1);//获得路由里面的分页数据
  111. //通过导航路径反向查询导航id
  112. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  113. method: 'GET',
  114. query: {
  115. 'pinyin': targetSegment1 + '/' + targetSegment2,
  116. },
  117. });
  118. if (getRouteId.code == 200) {
  119. articleId = getRouteId.data.category_id
  120. routeName = getRouteId.data.alias
  121. } else {
  122. console.log("后端错误反馈:", getRouteId.message)
  123. }
  124. pageNum.value = parseInt(route.params.id);
  125. //2.路径 end---------------------------------------->
  126. //3.列表 start ---------------------------------------->
  127. let total = ref(0);
  128. let pageSize = ref(15);
  129. const newsList = ref([]);
  130. let newslists = async () => {
  131. const listData = await requestDataPromise('/web/getWebsiteProjectList', {
  132. method: 'GET',
  133. query: {
  134. 'page': pageNum.value,
  135. 'pageSize': pageSize.value,
  136. 'category_id': articleId
  137. },
  138. });
  139. console.log("listData1111", listData);
  140. if (listData.code == 200) {
  141. newsList.value = listData.data.rows;
  142. total.value = listData.data.count;
  143. } else {
  144. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  145. console.log("错误位置:获取新闻列表")
  146. console.log("后端错误反馈:", listData.message)
  147. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  148. }
  149. }
  150. newslists();
  151. //分页
  152. let changePage = (value) => {
  153. console.log("当前页码", value);
  154. navigateTo(`/${targetSegment1}/${targetSegment2}/list-${value}.html`)
  155. }
  156. //3.列表 end ---------------------------------------->
  157. //4.面包屑 start---------------------------------------->
  158. //3.1 获得页面名称
  159. const name = ref('')
  160. let getPageName = async () => {
  161. const pageName = await requestDataPromise('/web/getOneWebsiteCategory', {
  162. method: 'GET',
  163. query: {
  164. 'catid': articleId
  165. },
  166. });
  167. if (pageName.code == 200) {
  168. name.value = pageName.data.alias
  169. } else {
  170. console.log("错误位置:设置页面标题")
  171. }
  172. }
  173. getPageName();
  174. //3.2 获得父级栏目
  175. const parent_name = ref([]);
  176. const parent_id = ref([]);
  177. const parent_pinyin = ref("");
  178. let getParentNav = async () => {
  179. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  180. method: 'GET',
  181. query: {
  182. 'catid': articleId
  183. },
  184. });
  185. if (listData.code == 200) {
  186. console.log(111999)
  187. console.log(listData.data);
  188. parent_name.value = listData.data.parent_name;
  189. parent_id.value = listData.data.parent_id;
  190. parent_pinyin.value = listData.data.parent_pinyin;
  191. } else {
  192. console.log("错误位置:获取父级栏目")
  193. }
  194. getSecondNav();
  195. }
  196. getParentNav();
  197. // 3.3获取二级栏目
  198. const secondNav = ref([]);
  199. let getSecondNav = async () => {
  200. const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
  201. method: 'GET',
  202. query: {
  203. 'placeid': 1,
  204. 'pid': parent_id.value,
  205. 'num': 20,
  206. },
  207. });
  208. console.log('listData', listData);
  209. if (listData.code == 200) {
  210. secondNav.value = listData.data;
  211. } else {
  212. console.log("错误位置:获取二级栏目列表")
  213. }
  214. }
  215. //4.面包屑 end ---------------------------------------->
  216. //5.设置seo信息 start---------------------------------------->
  217. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  218. method: 'GET',
  219. query: {
  220. 'catid': articleId
  221. },
  222. });
  223. if (setData.code == 200) {
  224. let seoTitle = setData.data.seo_title;
  225. let seoDescription = setData.data.seo_description;
  226. let seoKeywords = setData.data.seo_keywords;
  227. let seoSuffix = setData.data.suffix;
  228. let seoName = setData.data.website_name;
  229. useSeoMeta({
  230. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  231. meta: [
  232. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  233. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  234. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  235. ]
  236. });
  237. } else {
  238. console.log("错误位置:设置列表页面SEO数据")
  239. }
  240. //5.设置seo信息 end---------------------------------------->
  241. //6.广告 start---------------------------------------->
  242. let adImg1 = ref({});
  243. let adImg2 = ref({});
  244. onMounted(async () => {
  245. //从客户端获取行政职能部门 加快打开速度
  246. const { $webUrl, $CwebUrl } = useNuxtApp();
  247. //广告1
  248. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_list_0001`
  249. const responseAd1 = await fetch(url, {
  250. headers: {
  251. 'Content-Type': 'application/json',
  252. 'Userurl': $CwebUrl,
  253. 'Origin': $CwebUrl
  254. }
  255. });
  256. const resultAd1 = await responseAd1.json();
  257. adImg1.value = resultAd1.data[0];
  258. //广告2
  259. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmgw_list_0002`
  260. const responseAd2 = await fetch(url2, {
  261. headers: {
  262. 'Content-Type': 'application/json',
  263. 'Userurl': $CwebUrl,
  264. 'Origin': $CwebUrl
  265. }
  266. });
  267. const resultAd2 = await responseAd2.json();
  268. adImg2.value = resultAd2.data[0];
  269. })
  270. //6.广告 end---------------------------------------->
  271. </script>
  272. <style lang="less" scoped>
  273. @import url('@/assets/css/project/list.less');
  274. </style>
  275. <style lang="less" scoped>
  276. @media screen and (min-width:801px){/*pc*/
  277. .page_pc_none {
  278. display: none !important;
  279. }
  280. .pc_none{display:none;}
  281. }
  282. @media screen and (max-width:800px){/*ipad_phone*/
  283. .index_main{width:100%;margin:0px auto 30px;}
  284. .breadcrumb_box {
  285. height: 22px;
  286. width: 92%;
  287. margin: 10px auto;
  288. word-break: keep-all;
  289. white-space: nowrap;
  290. overflow: hidden;
  291. text-overflow: ellipsis;
  292. font-size: 14px;
  293. color: #666;
  294. * {
  295. font-size: 14px;
  296. display: inline;
  297. color: #666;
  298. line-height: 22px;
  299. height: 22px;
  300. margin-right: 5px;
  301. }
  302. }
  303. .phone_li{
  304. width:92%;margin:10px auto 0px;
  305. border: solid 1px #DDDDDD;
  306. .phone_li_a{display:block;width:100%;}
  307. .phone_li_h4{
  308. display: block;
  309. width: 100%;
  310. box-sizing: border-box;
  311. padding: 0px 10px;
  312. color: #489D97;
  313. font-size: 16px;
  314. font-weight: bold;
  315. background: #F7FBFE;
  316. height: 40px;
  317. line-height: 40px;
  318. border-bottom: solid 1px #DDDDDD;
  319. }
  320. .phone_li_in{margin: 10px auto 10px;display:flex;}
  321. .phone_li_img_box{
  322. width: 33vw;margin:0px 10px 0px 10px;
  323. height: 33vw;float:left;}
  324. .phone_li_img_box img{display: block;
  325. width: 100%;
  326. height: 100%;}
  327. .phone_li_right{margin-right:10px;flex:1;}
  328. .phone_li_dot4{height:80px;line-height:20px;color:#666;font-size:14px;
  329. overflow:hidden;display:-webkit-box!important;-webkit-box-orient:vertical;-webkit-line-clamp:4;
  330. word-wrap: break-word;
  331. overflow-wrap: break-word;
  332. white-space: pre-wrap;
  333. word-break: break-all;
  334. }
  335. .phone_li_btn{
  336. color: #d31d33;
  337. float: right;
  338. font-size: 14px;
  339. height: 20px;margin-top:8px;
  340. line-height: 20px
  341. }
  342. }
  343. .img_ul_box{
  344. min-height:642px;
  345. margin-bottom:10px;
  346. }
  347. .pagination{width:100%;margin:0;}
  348. .pagination:deep(.el-pagination.is-background .el-pager li){
  349. margin: 0px 4px;
  350. }
  351. .page_phone_none {
  352. display: none !important;
  353. }
  354. .phone_none{display:none;}
  355. }
  356. </style>